package cn.quevo.cube.provide.define.validate.impl;

import cn.quevo.common.utils.EntityUtil;
import cn.quevo.cube.provide.define.entity.CubeColumnSequence;
import cn.quevo.cube.provide.define.entity.dto.CubeColumnDto;
import cn.quevo.cube.provide.define.validate.AbstractColumnTypeValidate;
import cn.quevo.cube.provide.define.validate.ColumnTypeValidate;

/**
 * 序列验证
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/12/14 5:40 PM
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
public abstract class SequenceValidate extends AbstractColumnTypeValidate implements ColumnTypeValidate {

    /**
     * 初始化序列信息
     *
     * @param cubeColumnDto
     * @author July july_sky@foxmail.com
     * @date 2018/12/14 10:35 AM
     * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
     */
    protected void initSequence(CubeColumnDto cubeColumnDto) {
        cubeColumnDto.setMinLength(null);
        cubeColumnDto.setMinLength(null);
        cubeColumnDto.setMaxValue(null);
        cubeColumnDto.setMinValue(null);
        cubeColumnDto.setDecimalNum(null);

        cubeColumnDto.setCubeColumnSequence(new CubeColumnSequence());
        EntityUtil.init(cubeColumnDto, cubeColumnDto.getCubeColumnSequence());
        cubeColumnDto.getCubeColumnSequence().setSequenceLabel(cubeColumnDto.getColumnLabel());
        cubeColumnDto.getCubeColumnSequence().setModelId(cubeColumnDto.getModelId());
        cubeColumnDto.getCubeColumnSequence().setSequenceName(cubeColumnDto.getColName() + "_SEQ");
    }
}
